<?php

/**
 * Mailbox form.
 *
 * @package    sf_sandbox
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
 */
class tiketForm extends BaseMailboxForm
{
  public function configure()
  {
  	unset( 
  		$this['created_at'],  
  		$this['updated_at'],  
  		$this['pub'], 
  		$this['del_sender'], 
  		$this['del_resiver'], 
  		$this['comment'],
  		$this['translate'],
  		$this['fl_read'],
  	$this['from_partner_id'],
  	$this['to_partner_id'],
  		$this['fl_translate']);
  	
  		
  	  $this->setWidgets(array(
          'id'               => new sfWidgetFormInputHidden(),
  	  'from_id'          => new sfWidgetFormInputHidden( array (), array ('value' => sfContext::getInstance()->getUser()->getAttribute( 'user_id', null, 'sfGuardSecurityUser' ))),
  	  'body' => new sfWidgetFormTextarea(array(),array('class'=>'mailbox_body','style'=>'width:90%;')),
    ));


    
    		  /////Статус ссылки
		 if(sfContext::getInstance()->getRequest()->getParameter('id')>0)
		 {
		 	//die('111111');			 		
		      $this->widgetSchema['to_id'] =  new sfWidgetFormInputHidden(array(),array('value'=>sfContext::getInstance()->getRequest()->getParameter('id'),'size'=>10));
		 		
		 }
		 else 
		 {
                            if(sfContext::getInstance()->getUser()->isSuperAdmin())
                                {
                                   $this->widgetSchema['to_id'] =  new sfWidgetFormChoice(array('choices' => sfGuardUserPeer::getAllPartnersArray()));
                                }
                            else
                                {
                                	//die('222');
                                       $this->widgetSchema['to_id'] =  new sfWidgetFormInputHidden(array(),array('value'=>2,'size'=>10));
                                }
		 	 
		 }
		 ////
    
            $custom_decorator = new sfWidgetFormSchemaFormatterDefList($this->getWidgetSchema());
        $this->getWidgetSchema()->addFormFormatter('deflist', $custom_decorator);
        $this->getWidgetSchema()->setFormFormatterName('deflist');
    $this->validatorSchema->setOption ( 'allow_extra_fields', true );
    $this->widgetSchema->setNameFormat('mailbox[%s]');
    
    //$this->embedI18n(sfContext::getInstance()->getUser()->getLangs());
    
      	   // $js_path = '/js/tiny_mce/tiny_mce.js';
           //sfContext::getInstance()->getResponse()->addJavascript($js_path);
    
  }
}
class sfWidgetFormSchemaFormatterDefList extends sfWidgetFormSchemaFormatter {
    protected
      $rowFormat                 = '<div class="sf_admin_form_row">%label%%error%%field%%help%%hidden_fields%</div>',
      $helpFormat                = '<span class="help">%help%</span>',
      $errorRowFormat            = '<dt class="error">Errors:</dt><dd>%errors%</dd>',
      $errorListFormatInARow     = '<ul class="error_list">%errors%</ul>',
      $errorRowFormatInARow      = '<li>%error%</li>',
      $namedErrorRowFormatInARow = '<li>%name%: %error%</li>',
      $decoratorFormat           = '<dl id="formContainer">%content%</dl>';
}